<template>
  <div>
    <div class="top">
      <van-icon @click="goback" class="zuo" name="arrow-left" />
      详情
    </div>
    <div>
      <h2></h2>
      <!-- 商品详情 -->
      <img :src="goods.img1" />
      <span class="col">￥{{ goods.originprice }}</span>
      <span class="size">销量:{{goods.sales}}</span>
      <p>商品名称：{{ goods.proname }}</p>
    </div>
    <van-goods-action>
      <van-goods-action-icon icon="chat-o" text="客服" color="#ee0a24" />
      <van-goods-action-icon icon="cart-o" text="购物车" />
      <van-goods-action-icon icon="star" text="已收藏" color="#ff5000" />
      <van-goods-action-button type="warning" text="加入购物车" />
      <van-goods-action-button type="danger" text="立即购买" />
    </van-goods-action> 
  </div>
</template>

<script>
export default {
  name: "GoodsDetail",
  data() {
    return {
      goods: {},
      proid: "",
    };
  },
  created() {
    this.proid = this.$route.params.good;
    console.log("this.proid  " + this.proid);
    this.$server({
      url: "/pro/detail/" + this.proid,
    }).then((res) => {
      let data = res.data;
      console.log(data);
      if (data.code == 200) {
        this.goods = data.data;
      }
    });
  },
  methods: {
    goback() {
      this.$router.replace("/");
    },
  },  
};
</script>

<style scoped>
.top {
  width: 100%;
  height: 3.75rem;
  font-size: 1.25rem;
  text-align: center;
  line-height: 3.75rem;
  border-bottom: 0.0625rem solid black;
  position: relative;
}
.zuo {
  position: absolute;
  left: 0.625rem;
  font-size: 1.25rem;
  top: 1.375rem;
}
.col {
  color: red;
  font-size: 1.25rem;
}
img{
  width: 100%;
  height: 25rem;
}
.size{
  font-size: .75rem;
  position: absolute;
  right: .3125rem;
}
</style>